package com.ctosb.classviewer.clazz.attr;

import com.ctosb.classviewer.ClassReader;
import com.ctosb.classviewer.clazz.AbstractParse;
import com.ctosb.classviewer.clazz.cp.CONSTANT_Utf8_info;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class Enum_const_value extends AbstractParse {

    private short type_name_index;
    private short const_name_index;

    @Override
    public Enum_const_value parse(ClassReader classReader) {
        this.type_name_index = classReader.readShort();
        this.const_name_index = classReader.readShort();
        return this;
    }

    public String getType_name() {
        return ((CONSTANT_Utf8_info) getClassFile().getConstant_pool()[type_name_index]).getValue();
    }

    public String getConst_name() {
        return ((CONSTANT_Utf8_info) getClassFile().getConstant_pool()[const_name_index]).getValue();
    }
}